package com.voicechat.firstmet.net.service;

import android.text.TextUtils;
import android.util.Log;

import com.voicechat.firstmet.bean.MySelfInfoBean;
import com.voicechat.firstmet.bean.Result;
import com.voicechat.firstmet.net.Params;

import rx.Observable;

/**
 * @ProjectName: FirstMet
 * @Package: 登录注册模块service
 * @ClassName: LoginService
 * @Description: 登录、注册service
 * @Author: ljp
 * @CreateDate: 2018/9/17 19:23
 * @Version: 1.0
 */
public class LoginService extends BaseService {
    /**
     * 短信验证码类型
     */
    public interface VALIDATE_CODE_TYPE {
        String VERIFY_CODE_REGISTER= "1";//注册验证码类型
        String VALIDATE_CODE_LOGIN = "6";//登录验证码类型
        String VALIDATE_CODE_CHANGE = "2";//修改登录密码验证码类型
        String VALIDATE_CODE_REALNAME = "4";//实名认证获取验证码
        String VALIDATE_CODE_PHONENUMBER = "5";//实名认证获取验证码
        String VALIDATE_CODE_WITHDRAW = "7";//提现
    }
    /**
     * @return
     * @method
     * @description 登录注册判断
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> registerJud(String mobile) {
        Params params = new Params();
        params.put("mobile", mobile);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.registerJud(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 校验验证码是否正确(除登录)
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> verificationCode(String mobile,String code) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("code", code);
        //params.put("type", type);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.verificationCode(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 校验验证码是否正确（只限登录）
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<MySelfInfoBean> verificationCodeLogin(String mobile,String code,String equipmentId) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("code", code);
        //手机设备码
        params.put("equipmentId", equipmentId);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.verificationCodeLogin(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 注册用户设置密码
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<MySelfInfoBean> registerPassword(String mobile,String pwd,String equipmentId,String channel) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("pwd", pwd);
        //手机设备码
        params.put("equipmentId", equipmentId);
        // /*渠道号*/
        params.put("channel", channel);
        Log.i("LoginService", "" + params.toString());
        return sNetInterface.registerPassword(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 输入密码登录
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<MySelfInfoBean> loginPassword(String mobile, String pwd, String equipmentId) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("pwd", pwd);
        params.put("equipmentId",equipmentId);
        Log.i("LoginService", "" + params.toString());
        return sNetInterface.loginPassword(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 验证码登录(发送验证码)
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> loginGetVCode(String mobile,String type) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("type", type);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.loginGetVCode(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 忘记密码
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> forgetPassword(String mobile,String password,String equipmentId,String code) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("pwd", password);
        params.put("equipmentId",equipmentId);
        if(!TextUtils.isEmpty(code)){
            params.put("code",code);
        }
       // Log.i("LoginService", "" + params.toString());
        return sNetInterface.forgetPassword(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 修改密码
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> alterPassword(String mobile,String password,String equipmentId,String code,String token) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("pwd", password);
        params.put("equipmentId",equipmentId);
        params.put("code",code);
        params.put("token",token);
         Log.i("LoginService", "" + params.toString());
        return sNetInterface.alterPassword(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 判断是否填写资料
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> dataValidation(String mobile,String token,String equipmentId) {
        Params params = new Params();
        params.put("mobile", mobile);
        params.put("token", token);
        params.put("equipmentId",equipmentId);
         Log.i("LoginService", "" + params.toString());
        return sNetInterface.dataValidation(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 完善资料
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<MySelfInfoBean> addData(String userId,String token,String avatarUrl,
                                             String gender,String nickName,String birthday,
                                                     String constellation,String equipmentId,String city,String province) {
        Params params = new Params();
        params.put("id", userId);
        params.put("token", token);
        params.put("avatarUrl",avatarUrl);
        params.put("gender",gender);
        params.put("nickName",nickName);
        params.put("birthday",birthday);
        params.put("constellation",constellation);
        params.put("equipmentId",equipmentId);
        params.put("ascription",city);//所在地
        params.put("province",province);//所在地
        Log.i("LoginService", "" +sNetInterface.toString()+ params.toString());
        return sNetInterface.addData(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 退出登录
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> loginExit(String mduserId,String token,String equipmentId) {
        Params params = new Params();
        params.put("id", mduserId);
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        //Log.i("LoginService", "" + params.toString());
        return sNetInterface.loginExit(params).compose(applySchedulers());
    }
}
